package edu.ucla.whi.wanda;

import org.restlet.Restlet;
import org.restlet.ext.wadl.WadlApplication;
import org.restlet.routing.Router;

public class DBServerApplication extends WadlApplication {
	public static final String name = "WANDA RESTful DB Interface";
	public static final String description = "WANDA RESTful DB Interface";
	
	public DBServerApplication() {
		super();
		setName(name);
		setDescription(description);
	}
	
	@Override
	public Restlet createInboundRoot() {
		// turn on compression
		getEncoderService().setEnabled(true);		
		
		Router router = new Router(getContext()); 
		
		// root
		router.attach(RootResource.path, RootResource.class);

		// reset
		router.attach(ResetResource.path, ResetResource.class);

		// subjects
		router.attach(SubjectListResource.path, SubjectListResource.class);
		router.attach(SubjectNewResource.path, SubjectNewResource.class);
		router.attach(SubjectItemResource.path, SubjectItemResource.class);
		router.attach(SubjectMeasurementsResource.path, SubjectMeasurementsResource.class);
		router.attach(SubjectEventsResource.path, SubjectEventsResource.class);

		// sensors
		router.attach(SensorListResource.path, SensorListResource.class);
		router.attach(SensorNewResource.path, SensorNewResource.class);
		router.attach(SensorItemResource.path, SensorItemResource.class);
		router.attach(SensorMeasurementsResource.path, SensorMeasurementsResource.class);
		
		// measurements
		router.attach(MeasurementListResource.path, MeasurementListResource.class);
		router.attach(MeasurementNewResource.path, MeasurementNewResource.class);
		router.attach(MeasurementItemResource.path, MeasurementItemResource.class);
		router.attach(MeasurementSearchResource.path, MeasurementSearchResource.class);

		// events
		router.attach(EventListResource.path, EventListResource.class);
		router.attach(EventNewResource.path, EventNewResource.class);
		router.attach(EventItemResource.path, EventItemResource.class);
		
		return router;
	}
}